package sample.data;

import com.google.gson.Gson;
import org.dreamwork.gson.GsonHelper;
import org.dreamwork.gson.TypeAdapterWrapper;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 * Created with IntelliJ IDEA.
 * User: seth.yang
 * Date: 12-11-7
 * Time: 下午12:58
 */
public class Person {
    private Gender gender;
    private int age;
    private String name;

    public Gender getGender () {
        return gender;
    }

    public void setGender (Gender gender) {
        this.gender = gender;
    }

    public int getAge () {
        return age;
    }

    public void setAge (int age) {
        this.age = age;
    }

    public String getName () {
        return name;
    }

    public void setName (String name) {
        this.name = name;
    }

    @Override
    public String toString () {
        return GsonHelper.getGson ().toJson (this);
    }

    public static void main (String[] args) throws Exception {
/*
        Person p = new Person ();
        p.setAge (35);
        p.setGender (Gender.Male);
        p.setName ("Seth.Yang");

        Gson g = GsonHelper.getGson ();
        String expression = g.toJson (p);
//        g = GsonHelper.getGson (false, new TypeAdapterWrapper ())
        System.out.println (expression);

        Person p1 = g.fromJson (expression, Person.class);
        System.out.println (p1);

        System.out.println (Gender.class.isEnum () + ", " + (Gender.Male instanceof Enum));

        System.out.println (g.toJson ("abc"));

        System.out.println (g.fromJson ("True", boolean.class));
*/
        Class c = Product.class;
        for (Method m : c.getMethods ()) {
            System.out.println (m.getName () + " -> " + m.getDeclaringClass ());
        }
    }
}
